

//
//  ZYExpiredCell.m
//  BestLearning
//
//  Created by Ethan on 2017/9/21.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "ZYExpiredCell.h"

@implementation ZYExpiredCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpSuperView];
        
    }
    
    return self;
}

- (void)assignByZYPendingUseModel:(ZYExpiredModel *)model{
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@",model.endTime];
    self.moonCakeLabel.text = [NSString stringWithFormat:@"%@",model.name];
    
    if (3== [model.status integerValue]) {
         [self.exchangeButton setTitle:@"已兑换" forState:(UIControlStateNormal)];
    }else if (4 == [model.status integerValue]){
         [self.exchangeButton setTitle:@"已过期" forState:(UIControlStateNormal)];
    }
    
    
}
- (void)setUpSuperView{
    UIImageView *imageView = [UIImageView new];
    imageView.image = [UIImage imageNamed:@"bg_voucher_lost_efficacy"];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:imageView];
    self.moonCakeLabel = [UILabel new];
    self.moonCakeLabel.font = [UIFont systemFontOfSize:16];
    self.moonCakeLabel.textColor = ColorRGB(251, 189, 129);
    [imageView addSubview:self.moonCakeLabel];
    
    self.timeLabel = [UILabel new];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    self.timeLabel.textColor = ColorRGB(102, 102, 102);
    [imageView addSubview:self.timeLabel];
    
    self.exchangeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
   
    [self.exchangeButton setTitleColor:ColorRGB(254, 254, 254) forState:(UIControlStateNormal)];
    self.exchangeButton.titleLabel.font = [UIFont systemFontOfSize:22];
    [imageView addSubview:self.exchangeButton];
    
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.offset(0);
        make.right.equalTo (self).offset(0);
        make.height.offset(100);
    }];
    self.moonCakeLabel.text = @"月饼";
    [self.moonCakeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(30);
    }];
    
    self.timeLabel.text = @"2017-10-9";
    
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moonCakeLabel);
        make.top.equalTo(self.moonCakeLabel.mas_bottom).offset(8);
    }];
    
    
    [self.exchangeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
        make.centerY.equalTo(imageView);
        make.width.offset(80);
        make.height.offset(80);
    }];
    
    UILabel *grayLabel = [UILabel new];
    grayLabel.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayLabel];
    
    [grayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(imageView.mas_bottom).offset(0);
        make.width.offset(SCREEN_WIDTH);
        make.height.offset(8);
    }];
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(grayLabel).offset(0);
    }];
    
    
    
    
    
}



@end
